<?php
class MessageBase extends BaseApp {
	var $msg = '';
	var $skip_time = '3000';
	var $url = '';
	var $is_ajax = 0;
	var $title = '';

	function __construct($array = array ()) {
		$this->Message($array);
	}
	function Message($array = array ()) 
	{
	    if(!isset($array['msg']))
		{
		 $array['msg'] = '';
		}
	    if(!isset($array['title']))
		{
		 $array['title'] = '';
		}		
	    if(!isset($array['taget']))
		{
		 $array['taget'] = '';
		}		
	    if(!isset($array['is_ajax']))
		{
		 $array['is_ajax'] = '';
		}
	    if(!isset($array['skip_time']))
		{
		 $array['skip_time'] = '';
		}
	    if(!isset($array['url']))
		{
		 $array['url'] = '';
		}		
		$this->msg = nl2br($array['msg']);

		$this->title = $array['title'];

		if (!empty ($array['is_ajax'])) {
			$this->is_ajax = $array['is_ajax'];
		}

		if (!empty ($array['skip_time'])) {
			$this->skip_time = $array['skip_time'];
		}

		if (!empty ($array['url'])) 
		{
		    if($array['url']=='reload')
			{
			$this->url = "location.href='".FROM_URL."'";			
			}
			else
			{
			$this->url = "location.href='$array[url]'";			
			}		

		} else {
			$this->url = 'javascript:history.back()';
		}
	}

	/**
	 * 显示消息页面
	 *
	 * @author  wj
	 * @return  void
	 */
	function display() {
		$this->msg = str_replace(ROOT_PATH, '', $this->msg);

		if ($this->is_ajax) {

		} else {
			if ($this->url) {
				$this->url = str_replace('&amp;', '&', $this->url); //$this->url 是给js使用的,不能包含&amp;
			}
			$this->assign('page_title', 'notice -- Powered by PHPSCUP');
			$this->assign('view_charset', VIEW_CHARSET);
			$this->assign('page_description', '');
			$this->assign('page_keywords', '');				
		    $this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');				
			$this->assign('web_view_dir', SITE_URL . '/admin/view/default/');
			$this->assign('title', $this->title);
			$this->assign('msg', $this->msg);
			$this->assign('url', $this->url);
			$this->assign('skip_time', $this->skip_time);
			parent :: display('message.view.html');
		}
		exit;
	}
}
?>